package az.mecid.rssreader.model.dao;

import az.mecid.rssreader.model.entity.FeedEntity;
import az.mecid.rssreader.model.entity.SubscriptionEntity;
import az.mecid.rssreader.model.utils.EMF;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserServiceFactory;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

/**
 * Created by IntelliJ IDEA.
 * User: mega
 * Date: 27.09.2010
 * Time: 1:17:20
 * To change this template use File | Settings | File Templates.
 */
public class SubscribeDAOImpl implements SubscribeDAO{
    public void save(SubscriptionEntity subscription) {
        EntityManager em = EMF.get().createEntityManager();
        EntityTransaction tx = em.getTransaction();
        try{
            tx.begin();
            em.persist(subscription);
            tx.commit();
        }finally {
            if(tx.isActive())
                tx.rollback();
        }
    }
}
